package com.liyiruo.dwb.controller;

import com.liyiruo.dwb.domain.Test;
import com.liyiruo.dwb.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author liyiruo
 * @Description
 * @Date 2021/11/23 下午11:08
 */
@RestController
public class TestController {

    @Autowired
    TestService testService;
    @Value("${my.name:6666}")
    String myname;

    //    @RequestMapping("/hello")
    @GetMapping("/hello")
    public String hello() {
        return "hello world";
    }

    @PostMapping("/hello2")
    public String helloPost(Map map) {
        return "hello world post" + map.get("name");
    }

    @PostMapping("/hello3")
    public String helloPost2(String name) {
        return "hello world post " + myname;
    }

    @GetMapping("/list")
    public List<Test> list() {
        System.out.println("--------------");
        return testService.list();
    }
}
